
A = ./
B =./doc/
CC = gcc
all: $(A)lsq   $(A)lsq_data  $(A)testdata.txt   doc exe

exe:
$(A)lsq: src/lsq.c
	$(CC) -o  $@  $<

$(A)lsq_data: src/lsq_data.c
	$(CC) -o  $@ $<

$(A)testdata.txt: lsq_data 
	$(A)$^
	./lsq

output.eps: testdata.txt
	gnuplot lsq.gp
	mv output.eps ./doc/

doc: $(B)lsq.tex output.eps $(B)references.bib
	cd ./doc && xelatex lsq
	cd ./doc && bibtex lsq
	cd ./doc && xelatex lsq
	cd ./doc && xelatex lsq

clean:
	rm -rf ./doc/*.aux ./doc/*.bbl ./doc/*.blg ./doc/*.log *.out ./doc/*.pdf *.toc \
	lsq testdata.txt lsq_data  $(B)*.eps \
	*.nav *.snm *.dat
.PHONY: all clean



